<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:th="http://www.thymeleaf.org">
<head th:include="/common/shop_common :: source"></head>

<style>
    .panel-group{max-height:770px;overflow: auto;}
    .leftMenu{margin:10px;margin-top:5px;}
    .leftMenu .panel-heading{font-size:14px;padding-left:20px;height:36px;line-height:36px;color:white;position:relative;cursor:pointer;}/*转成手形图标*/
    .leftMenu .panel-heading span{position:absolute;right:10px;top:12px;}
    .leftMenu .menu-item-left{padding: 2px; background: transparent; border:1px solid transparent;border-radius: 6px;}
    .leftMenu .menu-item-left:hover{background:#C4E3F3;border:1px solid #1E90FF;}
</style>

<body>
	<div th:include="/common/shop_common :: header"></div>
	<!--banner-->
	<div class="banner-top">
		<div class="container">
			<h2 class="animated wow fadeInLeft" data-wow-delay=".5s">Products</h2>
			<h3 class="animated wow fadeInRight" data-wow-delay=".5s">
				<a href="index.html">Home</a><label>/</label>Fruits<label>/</label>Women's
			</h3>
			<div class="clearfix"></div>
		</div>
	</div>
	
	<div th:include="/common/shop_common :: leftmenu"></div>
	<!-- contact -->
	<div style="padding:1em 0 0">
		<div class="container" style="width:1300px;height:800px">
			<div class="panel panel-default">
			    <div class="panel-heading">
			        <h3 class="panel-title">
			            <a>修改密码</a>
			        </h3>
			    </div>
			    <div class="panel-body">
			    	<form action="">
				        <div class="input-group" style="width:300px;height:45px">
				            <span class="input-group-addon">当前密码</span>
				            <input id="oldPassword" style="width:300px;height:45px" type="text" class="form-control" placeholder="当前密码" required="">
				        </div>
				        <br>
				        <div class="input-group" style="width:300px;height:45px">
				            <span class="input-group-addon">新  密 码</span>
				            <input id="newPassword" style="width:300px;height:45px" type="text" class="form-control" placeholder="新  密 码" required="">
				        </div>
				        <br>
				        <div class="input-group" style="width:300px;height:45px">
				            <span class="input-group-addon">确认密码</span>
				            <input id="againPassword" style="width:300px;height:45px" type="text" class="form-control" placeholder="初始密码" required="">
				        </div>
				        <br>
				        <div class="input-group" style="width:300px;height:45px">
				            <a class="btn btn-danger" th:onclick="'javascript:changePassword()'">修改密码</a>
				        </div>
				        <br>
			        </form>
			    </div>
			</div>
		</div>
	</div>
	<script type="text/javascript" th:inline="javascript">
	//页面初始化加载
	$(function(){
		
		//加载商品信息,初始化不对商品进行搜索
		//getProducts("","","","");
	})
	
	function changePassword(){
		var oldPassword = $("#oldPassword").val();
		var newPassword = $("#newPassword").val();
		var againPassword = $("#againPassword").val();
		if(typeof(oldPassword) == undefined || oldPassword == null){
			layer.msg('参数不能为空', {icon: 2});
			return;
		}else if(typeof(newPassword) == undefined || newPassword == null){
			layer.msg('参数不能为空', {icon: 2});
			return;
		}else if(typeof(againPassword) == undefined || againPassword == null){
			layer.msg('参数不能为空', {icon: 2});
			return;
		}else if(againPassword != newPassword){
			layer.msg('确认密码不一致', {icon: 2});
			return;
		}
		layer.confirm('确定修改密码？', {
			  btn: ['取消','确定']
			}, function(){
			  layer.msg('请继续操作', {icon: 6});
			}, function(){
				$.ajax({  
		            type: 'post',  
		            dataType: 'json',  
		            url: basePath + '/user/changePassword',  
		            data: {
		            	oldPassword:oldPassword,
		            	newPassword:newPassword,
		            	againPassword:againPassword
		            },  
		            cache: false,  
		            async: true,  
		            success: function (data) {
		            	if(data.code!="200"){
		            		layer.msg(data.msg, {icon: 2});
		            	}else{
		            		layer.alert('密码修改成功，请重新登陆', {icon: 6},function(){
		            			window.location.href=basePath+"/user/login"
		            		});
		            	}
		            }  
		        });
			});
	}
	</script>
</body>
</html>